<template>
	<!-- <scroll-view class="content" @touchmove.prevent.stop="move" :style="{'top':navHeight+'px'}"> -->
		<!-- <mescroll ref="mescrollRef" :top="0" :down="downOption" :up="upOption" :bottom="0"
			@init="mescrollInit" @down="downCallback" @up="upCallback">
			<u-search @change="search" v-model="keyword" shape="round" bgColor="#FFFFFF" :showAction="false"></u-search>
			<view v-for="(item,index) in dataList" :key="index">
				<bike-site-cell @click.native="cell_Click(item)" :data="item"></bike-site-cell>
			</view>
			<empty :show="showEmpty"></empty>
		</mescroll> -->
		<view>
			<u-search @change="search" v-model="keyword" shape="round" bgColor="#FFFFFF" :showAction="false"></u-search>
			<view v-for="(item,index) in dataList" :key="index" @click.stop="cell_Click(item)">
				<bike-site-cell  :data="item"></bike-site-cell>
			</view>
			<empty :show="showEmpty"></empty>
		</view>
		
		<!-- <loading-page :loading="loading"></loading-page>
		<view v-if="!loading">
			<view>
				<mescroll-body ref="mescrollRef" :top="0" :down="downOption" :up="upOption" :bottom="0"
					@init="mescrollInit" @down="downCallback" @up="upCallback">
					<u-search @change="search" v-model="keyword" shape="round" bgColor="#FFFFFF" :showAction="false"></u-search>
					<view v-for="(item,index) in dataList" :key="index">
						<bike-site-cell @click.native="cell_Click(item)" :data="item"></bike-site-cell>
					</view>
					<empty :show="showEmpty"></empty>
				</mescroll-body>
			</view>
		</view> -->
	<!-- </scroll-view> -->
</template>

<script>
	import bikeSiteCell from '../components/bikeSiteCell.vue'
	import * as siteApi from '../../api/site/index.js'
	import empty from './@/components/empty.vue'
	import MescrollMixin from "@/components/mescroll-uni/components/mescroll-uni/mescroll-mixins.js"
	import mescroll from "@/components/mescroll-uni/components/mescroll-diy/beibei/mescroll-uni.vue"
	import {
		paging
	} from '@/mixins/paging.js'
	var globalData=getApp({allowDefault: true}).globalData
	export default {
		mixins: [MescrollMixin, paging],
		components: {
			bikeSiteCell,
			mescroll,
			empty
		},
		data() {
			return {
				navHeight:0,
				dataList: [],
				loading: true,
				keyword:'',
				query:{
					pageNum:1
				},
				complete:null,
				fail:null
			}
		},
		mounted() {
			this.getSiteList()
			this.navHeight=globalData.titleHeight;
		},
		onUnload() {
			// this.canScroll()
		},
		methods: {
			search(value) {
				this.query.pageNum = 1;
				this.dataList = [];
				this.keyword=value;
				this.getSiteList()
			},
			cell_Click(item) {
				console.log("22222")
				uni.navigateTo({
					url: '/pages/site/bikeSiteDetail?id=' + item.id
				})
			},
			
			loadNext(num, complete,fail){
				this.query.pageNum = num
				this.complete=complete
				this.fail = fail
				this.getSiteList()
			},
			
			getSiteList() {
				siteApi.getChargingGroupList(0,this.keyword, this.query.pageNum).then((res) => {
					this.loading=false;
					this.complete(res.data.records.length,res.data.records.length<10?false:true)
					// this.mescroll.endSuccess(res.data.records.length, res.data.records.length<10?false:true)
					if (this.query.pageNum === 1) {
						this.dataList = []
					}
					this.dataList = this.dataList.concat(res.data.records)
					this.showEmpty=this.dataList.length==0?true:false
				}).catch((errMsg)=>{
					this.loading=false;
					this.fail()
					// this.mescroll.endErr();
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		margin: 0rpx 30rpx 30rpx 30rpx;
		padding-top:20rpx;
		position: fixed;
		background-color: red;
		left:0rpx;
		right:0rpx;
		bottom:0rpx;
		top:0rpx;
		width:calc(100% - 60rpx);
	}
</style>
